﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using gnet1.Models;

namespace gnet1.Controllers
{
    public class FitnessController : Controller
    {
        //
        // GET: /Fitness/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult BmiCalculation()
        {
          var model = new BmiViewModel();
          return View(model);
        }

        public ActionResult BmiWidget()
        {
          return View();
        }

        public ActionResult FoodChoicesWidget()
        {
          return View();
        }
        
        [HttpPost]
        public ActionResult BmiResults(BmiViewModel model)
        {
          model.BMI = model.WeightInPounds / Math.Pow(model.HeightInInches, 2.0) * 703.0;

          if (model.BMI > 50.0)
            model.Status = "Super Obese";
          else if (model.BMI > 40.0)
            model.Status = "Mobidly Obese";
          else if(model.BMI > 35.0)
            model.Status = "Obese Class II";
          else if (model.BMI > 30.0)
            model.Status = "Obese Class I";
          else if (model.BMI > 25.0)
            model.Status = "Overweight";
          else if (model.BMI > 18.5)
            model.Status = "Normal";
          else
            model.Status = "Underweight";

          return View("BmiResults",model);
        } 
    }
}
